using UnityEngine;

public class FPSFlyCamera : MonoBehaviour
{
	public float Speed = 10f;

	public float sensitivityX = 15f;

	public float sensitivityY = 15f;

	public float minimumX = -360f;

	public float maximumX = 360f;

	public float minimumY = -60f;

	public float maximumY = 60f;

	private float rotationX;

	private float rotationY;

	private float speedmult = 1f;

	private void Start()
	{
	}

	private void Update()
	{
		base.transform.position += base.transform.forward * UnityEngine.Input.GetAxis("Vertical") * Speed * speedmult * Time.deltaTime;
		base.transform.position += base.transform.right * UnityEngine.Input.GetAxis("Horizontal") * Speed * speedmult * Time.deltaTime;
		rotationX += UnityEngine.Input.GetAxis("Mouse X") * sensitivityX;
		rotationY += UnityEngine.Input.GetAxis("Mouse Y") * sensitivityY;
		if (UnityEngine.Input.GetKey(KeyCode.LeftShift))
		{
			speedmult = 2f;
		}
		else
		{
			speedmult = 1f;
		}
		if (rotationX >= 360f)
		{
			rotationX = 0f;
		}
		if (rotationX <= -360f)
		{
			rotationX = 0f;
		}
		rotationX = ClampAngle(rotationX, minimumX, maximumX);
		rotationY = ClampAngle(rotationY, minimumY, maximumY);
		Quaternion lhs = Quaternion.AngleAxis(rotationX, Vector3.up);
		Quaternion rhs = Quaternion.AngleAxis(rotationY, Vector3.left);
		base.transform.localRotation = lhs * rhs;
	}

	private static float ClampAngle(float angle, float min, float max)
	{
		if (angle < -360f)
		{
			angle += 360f;
		}
		if (angle > 360f)
		{
			angle -= 360f;
		}
		return Mathf.Clamp(angle, min, max);
	}
}
